class Solution {


    public static void main(String[] args) {
        int[] arr={5,7,8,3,2,5,8,10};

        System.out.println(maxArea(arr));
    }
    public static int maxArea(int[] height) {

        int max=0;
        int left=0;
        int right=height.length-1;
        int h=0;
        while(left<right){

            h=Math.min(height[left],height[right]);
            max=Math.max(max,(right-left)*h);

            if( h==height[right]){
                while(left<right &&height[right]<=h){
                    right--;
                }
            }else if( h==height[left]){
                while(left<right &&height[left]<=h){
                    left++;
                }

            }



        }

        return max;




    }
}